// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

const db = cloud.database()
const _ = db.command

/**
 * 查询用户信息
 */
exports.main = async (event, context) => {
  const { OPENID } = cloud.getWXContext()
  return await db.collection('user')
    .where({ _openid: OPENID })
    .get()
}